import type { BasicColumn } from '/@/components/Table/src/types/table';
import type { FormProps } from '/@/components/Form';
import { h } from 'vue';
// import { h } from 'vue';
// import { Tag } from 'ant-design-vue/lib/components';

export function getUserColumns(): BasicColumn[] {
  return [
    {
      title: '手机号',
      width: 150,
      dataIndex: 'mobile',
      customRender: ({ record: { mobile } }) => {
        return mobile.replace(/(\d{3})\d{4}(\d{4})/, '$1****$2');
      },
    },
    {
      title: '昵称',
      dataIndex: 'nickname',
      width: 150,
    },
    {
      title: '年龄',
      dataIndex: 'age',
      width: 150,
    },
    {
      title: '性别',
      dataIndex: 'sex',
      width: 100,
      customRender: ({ record: { sex } }) => {
        return h('span', null, sex == 1 ? '女' : '男');
      },
    },
    {
      title: '状态',
      dataIndex: 'isDisabled',
      edit: true,
      editComponent: 'Switch',
      editValueMap: (value) => {
        return value ? '禁用' : '正常';
      },
      // customRender: ({ record: { isDisabled } }) => {
      //   return isDisabled ? '禁用' : '正常';
      // },
      editRender: ({ text }) => {
        // let color='color:green'
        return h('span', { style: text ? 'color:red' : 'color:green' }, text ? '禁用' : '正常');
      },
      width: 150,
    },
    {
      title: '注册时间',
      width: 150,
      sorter: true,
      dataIndex: 'gmtCreate',
    },
  ];
}
export function getSearchFormConfig(): Partial<FormProps> {
  return {
    labelWidth: 70,
    autoSubmitOnEnter: true,
    schemas: [
      {
        field: 'nickname',
        label: '昵称',
        component: 'Input',
        colProps: {
          xl: 4,
          xxl: 8,
        },
      },
      {
        field: 'age',
        label: '年龄',
        component: 'Select',
        colProps: {
          xl: 4,
          xxl: 8,
        },
        componentProps: {
          options: [
            {
              label: '3岁',
              value: 3,
              key: '3',
            },
            {
              label: '4岁',
              value: 4,
              key: '4',
            },
            {
              label: '5岁',
              value: 5,
              key: '5',
            },
            {
              label: '6岁',
              value: 6,
              key: '6',
            },
          ],
        },
      },
      {
        field: '[startTime, endTime]',
        label: '注册时间',
        component: 'RangePicker',
        componentProps: {
          format: 'YYYY-MM-DD HH:mm:ss',
          placeholder: ['开始时间', '结束时间'],
          showTime: { format: 'HH:mm:ss' },
        },
        colProps: {
          xl: 8,
          xxl: 8,
        },
      },
    ],
  };
}
